package cn.wh.mapping;

import cn.wh.session.Configuration;

/**
 * @Author wh
 * @Description 映射语句类
 * @Date 2023/1/30 14:17
 * @Version 1.0
 **/
public class MappedStatement {
    private Configuration configuration;

    private String id;

    //sql 指令类型
    private SqlCommandType sqlCommandType;

    //sql 源码
    private SqlSource sqlSource;

    Class<?> resultType;

    MappedStatement() {
        // constructor disabled
    }

    /**
     * 建造者
     */
    public static class Builder{

        private MappedStatement mappedStatement=new MappedStatement();

        public Builder(Configuration configuration,String id,SqlCommandType sqlCommandType,SqlSource sqlSource, Class<?> resultType){
            mappedStatement.configuration = configuration;
            mappedStatement.id = id;
            mappedStatement.sqlCommandType = sqlCommandType;
            mappedStatement.sqlSource=sqlSource;
            mappedStatement.resultType=resultType;

        }

        public MappedStatement build() {
            assert mappedStatement.configuration != null;
            assert mappedStatement.id != null;
            return mappedStatement;
        }
    }


    public Configuration getConfiguration() {
        return configuration;
    }

    public String getId() {
        return id;
    }

    public SqlCommandType getSqlCommandType() {
        return sqlCommandType;
    }

    public SqlSource getSqlSource() {
        return sqlSource;
    }

    public Class<?> getResultType() {
        return resultType;
    }
}
